﻿using Domain.Flow;
using MediatR;
using U.B.ErrorCode;
using U.B.ReadApi.Command.Raddit.BW;
using U.B.Repistory;

namespace U.B.ReadApi.CommandHander.Raddit.BWHA
{
    public class GetproductclassCommandHander : IRequestHandler<GetproductclassCommand, ApiResult<List<ProductClass>>>
    {
        public IRepistory<ProductClass> _productClassRepistory;

        public GetproductclassCommandHander(IRepistory<ProductClass> productClassRepistory)
        {
            _productClassRepistory = productClassRepistory;
        }
        /// <summary>
        /// 商品类别表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<ApiResult<List<ProductClass>>> Handle(GetproductclassCommand request, CancellationToken cancellationToken)
        {
             ApiResult<List<ProductClass>> apiresult = new ApiResult<List<ProductClass>>();
             var result = _productClassRepistory.GetAll().ToList();
            apiresult.code = Renum.显示成功;
            apiresult.Message=Renum.显示成功.ToString();
            apiresult.Data = result;
            return Task.FromResult(apiresult); 
        }
    }
}
